<template>
  <div class="pageTitle">
    <van-icon class="backBtn" name="arrow-left" color="#969799" @click="back" />
    <div class="title">{{ title }}</div>
  </div>
</template>

<script>
export default {
  props: ["title"],
  methods: {
    back() {
      if (window.history.length <= 1) {
        this.$router.push("/");
      } else {
        this.$router.go(-1);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.pageTitle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  background-color: #fff;
  .backBtn {
    display: block;
    position: absolute;
    top: 16px;
    left: 16px;
    cursor: pointer;
    font-size: 24px;
    line-height: 24px;
  }
  .title {
    font-weight: bold;
    font-size: 17px;
  }
}
</style>